import 'package:fast_build/pages/chat/chat_page.dart';
import 'package:fast_build/pages/community/community_page.dart';
import 'package:fast_build/pages/home/home_page.dart';
import 'package:fast_build/pages/mine/mine_page.dart';
import 'package:fast_build/pages/order/order_page.dart';
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import 'package:hk_base/hk_base.dart';

class TabPageController extends GetxController with WidgetsBindingObserver {

  /// 未读消息数量
  final unReadNum = 0.obs;
  /// 申请好友数量
  final unreadCount = 0.obs;

  /// Tab栏信息
  List tabList = [
    {
      'img': 'assets/tab/home.png',
      'title': '首页',
      'selectImg': 'assets/tab/home_opt.png'
    },
    {
      'img': 'assets/tab/order.png',
      'title': '订单',
      'selectImg': 'assets/tab/order_opt.png'
    },
    {
      'img': 'assets/tab/home.png',
      'title': '',
      'selectImg': 'assets/tab/home_opt.png'
    },
    {
      'img': 'assets/tab/chat.png',
      'title': '消息',
      'selectImg': 'assets/tab/chat_opt.png'
    },
    {
      'img': 'assets/tab/my.png',
      'title': '我的',
      'selectImg': 'assets/tab/my_opt.png'
    }
  ];
  /// Tab视图List
  List<Widget> tabViewList = [
    HomePage(),
    OrderPage(),
    CommunityPage(),
    ChatPage(),
    MinePage()
  ];

  /// 已选择的Tab
  final tabIndex = 0.obs;
  /// 记录时间
  int lastTime = 0;
  @override
  void onInit() {
    // TODO: implement onInit
    WidgetsBinding.instance.addObserver(this);
    super.onInit();
  }

  @override
  void onClose() {
    WidgetsBinding.instance.removeObserver(this);
    super.onClose();
  }

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    switch (state) {
      case AppLifecycleState.resumed:
        HkLog.d('应用程序可见并响应用户输入。');
        break;
      case AppLifecycleState.inactive:
        HkLog.d('应用程序处于非活动状态，并且未接收用户输入');
        break;
      case AppLifecycleState.paused:
        HkLog.d('用户当前看不到应用程序，没有响应');
        break;
      case AppLifecycleState.detached:
        HkLog.d('应用程序将暂停。');
        break;
      default:
    }
  }
}
